<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/templates/interna.xhtml">

        <ui:define name="breadcrumb">

            <h:form>

                <p:breadCrumb>
                    <p:menuitem value="#{msg.principal}"/>
                    <p:menuitem value="#{msg.menuCadastros}"/>
                    <p:menuitem value="#{msg.subMenuFormatos}"/>
                    <p:menuitem value="#{msg.RF003_Formato_Cadastrar}" rendered="#{manterFormato.formato.id == null and !manterFormato.isDetalhamento}"/>
                    <p:menuitem value="#{msg.RF003_Formato_Editar}" rendered="#{manterFormato.formato.id != null and !manterFormato.isDetalhamento}"/>
                    <p:menuitem value="#{msg.RF003_Formato_Detalhar}" rendered="#{manterFormato.isDetalhamento}"/>
                </p:breadCrumb>

            </h:form>    

        </ui:define>

        <ui:define name="corpo">

            <h:form id="frmFormatos">

                <p:fieldset id="fsDadosFormatos" legend="#{msg.RF003_Dados_Formato}" toggleable="true">
                    
                    <h:panelGrid columns="2" cellspacing="2" cellpadding="2">

                        <p:outputLabel for="itCodigo" value="#{msg.RF003_Codigo}: "/>
                        <p:inputText id="itCodigo" value="#{manterFormato.formato.codigo}" style="width: 25em" maxlength="8" onkeydown="return somenteNumero(event)" required="true" requiredMessage="#{msg.RF003_Codigo}: #{msg.campo_obrigatorio}" disabled="#{manterFormato.isDetalhamento}"/>
                        
                        <p:outputLabel for="itDescricao" value="#{msg.RF003_Descricao}:" />
                        <p:inputText id="itDescricao" value="#{manterFormato.formato.descricao}" style="width: 85em" maxlength="50" onblur="upperCase(this)" required="true" requiredMessage="#{msg.RF003_Descricao}: #{msg.campo_obrigatorio}" disabled="#{manterFormato.isDetalhamento}"/>
                        
                    </h:panelGrid>

                </p:fieldset>

                <div class="espacamento"/>

                <div align="left">
                    
                    <p:commandButton value="#{msg.novo}" 
                                     icon="ui-icon-plusthick" 
                                     immediate="true"
                                     rendered="#{manterFormato.possuiPrivilegio('MANTER_FORMATO') and manterFormato.isDetalhamento}"
                                     action="#{manterFormato.setup()}"
                                     update="@form"
                                     oncomplete="scrollToTop('global');"/>
                    
                    <p:spacer width="5" rendered="#{loginUsuario.possuiPrivilegio('MANTER_FORMATO') and manterFormato.isDetalhamento}"/>
                    
                    <p:commandButton value="#{msg.editar}" 
                                     icon="ui-icon-clipboard" 
                                     immediate="true"
                                     rendered="#{loginUsuario.possuiPrivilegio('MANTER_FORMATO') and manterFormato.isDetalhamento}"
                                     process="@this"
                                     update="@form"
                                     oncomplete="scrollToTop('global');">
                        <f:setPropertyActionListener value="false" target="#{manterFormato.isDetalhamento}"/>
                    </p:commandButton>
                    
                    <p:spacer width="5" rendered="#{loginUsuario.possuiPrivilegio('MANTER_FORMATO') and manterFormato.isDetalhamento}"/>
                    
                    <p:commandButton value="#{msg.salvar}" 
                                     icon="ui-icon-disk" 
                                     rendered="#{!manterFormato.isDetalhamento}"
                                     action="#{manterFormato.salvar}"
                                     process="@form"
                                     update="@form"/>
                    
                    <p:spacer width="5" rendered="#{!manterFormato.isDetalhamento}"/>
                    
                    <p:commandButton value="#{msg.cancelar}" 
                                     icon="ui-icon-closethick"
                                     immediate="true"
                                     rendered="#{!manterFormato.isDetalhamento}"
                                     onclick="pnConfirmacao.show();">
                    </p:commandButton>	
                    
                    <p:spacer width="5" rendered="#{!manterFormato.isDetalhamento}"/>
                    
                    <p:commandButton value="#{msg.voltar}" 
                                     action="#{manterFormato.voltar}" 
                                     icon="ui-icon-arrowreturnthick-1-w"
                                     ajax="false"
                                     immediate="true"/>	
                </div>
                
            </h:form>
            
            <ui:include src="/restrito/painel_confirmacao.xhtml">
                <ui:param name="id" value="pnConfirmacao"/>
                <ui:param name="mensagem" value="#{msg.deseja_cancelar_operacao}"/>
                <ui:param name="bean" value="#{manterFormato}"/>
                <ui:param name="action" value="#{manterFormato.formato.id != null ? 'detalhar' : 'setup'}"/>
            </ui:include>

        </ui:define>

    </ui:composition>

</html>
